import React, { Component } from 'react';

// 导入推荐列表请求
import { Recommend } from '../api/index'

//导入并执行css样式
import "../styles/MySecKill.css"

class MySecKill extends Component {
    constructor(props) {
        super(props);
        this.state = {
            MySecKill: [

            ]
        }
    }
    // 挂载生命周期
    componentDidMount() {
        Recommend().then((res) => {//发请求
            // console.log(res.data.list);
            this.setState({ MySecKill: res.data.list })//渲染数据
            console.log(MySecKill);
        })
    }
    render() {
        return (
            <div className='MySecKill'>
                <div className='box'>
                    今日值得买
                </div>
                <div className='box1'>
                    {
                        //列表渲染过程中每个列表项必须有一个唯一的key值
                        this.state.MySecKill.map((item, index) => {
                            return (
                                <div className='item' key={index}>
                                    <img src={item.pic} alt="" />
                                    <div className='name'>{item.name}</div>
                                </div>
                            )
                        })
                    }
                </div>
            </div>
        );
    }
}

export default MySecKill;